USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_SEGURO_CESANTIA]    Script Date: 11/24/2011 14:36:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0002_SEGURO_CESANTIA]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0002_SEGURO_CESANTIA]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_SEGURO_CESANTIA]    Script Date: 11/24/2011 14:36:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[WASP_M0002_SEGURO_CESANTIA] 
AS 
BEGIN 
	CREATE TABLE seguro_ces (
		suc INT
		,cta NUMERIC
		,ope NUMERIC
		,cod_seg INT
		,val_seg FLOAT
	)

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg1, val_seg1
	FROM seguros WHERE cod_seg1 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg2, val_seg2
	FROM seguros WHERE cod_seg2 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg3, val_seg3
	FROM seguros WHERE cod_seg3 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg4, val_seg4
	FROM seguros WHERE cod_seg4 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg5, val_seg5
	FROM seguros WHERE cod_seg5 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg6, val_seg6
	FROM seguros WHERE cod_seg6 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg7, val_seg7
	FROM seguros WHERE cod_seg7 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg8, val_seg8
	FROM seguros WHERE cod_seg8 = 105

	INSERT INTO seguro_ces
	SELECT ppsuc, ppcta, ppoper, cod_seg9, val_seg9
	FROM seguros WHERE cod_seg9 = 105

	CREATE TABLE seguro_salud (suc int, cta numeric,
								   ope numeric, cod_seg int,
								   val_seg float)

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg1, val_seg1
	FROM seguros WHERE cod_seg1 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg2, val_seg2
	FROM seguros WHERE cod_seg2 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg3, val_seg3
	FROM seguros WHERE cod_seg3 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg4, val_seg4
	FROM seguros WHERE cod_seg4 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg5, val_seg5
	FROM seguros WHERE cod_seg5 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg6, val_seg6
	FROM seguros WHERE cod_seg6 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg7, val_seg7
	FROM seguros WHERE cod_seg7 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg8, val_seg8
	FROM seguros WHERE cod_seg8 = 106

	INSERT INTO seguro_salud
	SELECT ppsuc, ppcta, ppoper, cod_seg9, val_seg9
	FROM seguros WHERE cod_seg9 = 106
END

GO


